﻿namespace ufida.u9.ait.openapi
{
	using System;
	using System.Collections.Generic;
    using System.Text;
    using ufida.u9.ait.openapi.utils;
    using UFIDA.U9.CBO.Pub.Controller;
    using UFIDA.U9.PR.PurchaseRequest;
    using UFSoft.UBF.AopFrame;
    using UFSoft.UBF.Business;
    using UFSoft.UBF.Util.Context;

    /// <summary>
    /// PRSaveNoApproveSV partial 
    /// </summary>	
    public partial class PRSaveNoApproveSV
    {
        internal BaseStrategy Select()
        {
			return new PRSaveNoApproveSVImpementStrategy();	
		}		
	}
	
	#region  implement strategy	
	/// <summary>
	/// Impement Implement
	/// 
	/// </summary>	
	internal partial class PRSaveNoApproveSVImpementStrategy : BaseStrategy
	{
		public PRSaveNoApproveSVImpementStrategy() { }

		public override object Do(object obj)
		{						
			PRSaveNoApproveSV bpObj = (PRSaveNoApproveSV)obj;

            return CodeUtils.DocSaveRT(bpObj, bpObj.Data, PRBase.CreatePR,null);

            //try
            //{
            //    if (bpObj.Data == null || bpObj.Data.Count == 0)
            //        throw new Exception("传入参数为空");
            //    List<CommonArchiveDataDTOData> retlist = new List<CommonArchiveDataDTOData>();

            //    foreach (var dto in bpObj.Data)
            //    {
            //        PR item = PR.Finder.Find($"DocNo='{dto.DocNo}'");
            //        if (item == null)
            //        {
            //            //新增逻辑
            //            item = PRBase.CreatePR(dto);
            //            //修改单号
            //            using (ISession session = Session.Open())
            //            {
            //                item.DocNo = dto.DocNo;
            //                session.Commit();
            //            }
            //            //审核
            //            //item = PRBase.ApproveDoc(item);

            //            //返回值
            //            retlist.Add(new CommonArchiveDataDTOData
            //            {
            //                ID = item.ID,
            //                Code = item.DocNo
            //            });
            //        }
            //        else
            //        {
            //            //修改逻辑
            //            throw new AITException(599, $"单号:[{dto.DocNo}]已经存在,不能生成!");
            //        }
            //    }
            //    return ResultUtils.success(bpObj, bpObj.Data, retlist);
            //}
            //catch (Exception ex)
            //{
            //    return ResultUtils.error(bpObj, bpObj.Data, ex);
            //}
        }		
	}

	#endregion
	
	
}